package fang.controller;

import fang.pojo.School;
import fang.pojo.Student;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class ExpressController {

    @RequestMapping("/express-var")
    public String express_var(Model model) {
        // 添加简单类型数据
        model.addAttribute("myName", "张三");
        model.addAttribute("myAge", 22);

        // 添加对象类型数据
        Student stu = new Student();
        stu.setId(1001);
        stu.setName("李四");
        stu.setEmail("lisi@qq.com");
        stu.setAge(20);
        stu.sex = "男";

        School school = new School();
        school.setName("浙江中医药大学");
        school.setAddress("杭州-滨江");
        stu.setSchool(school);

        model.addAttribute("student", stu);
        return "var1";
    }
}
